package com.atguigu.common.validator;

import java.lang.reflect.Field;

/**
 * @author lvling
 */
public interface ValidationUtils {

    static Field getDeclaredField(Class clazz, String name) {
        try {
            Field field = clazz.getDeclaredField(name);
            if (!field.isAccessible()) {
                field.setAccessible(true);
            }
            return field;
        } catch (NoSuchFieldException e) {
            Class superClazz = clazz.getSuperclass();
            if (superClazz != null) {
                return getDeclaredField(superClazz, name);
            } else {
                return null;
            }
        }
    }

}
